#pragma once
#include "EXEdit.h"
#include "EXDropdownComboBoxResSet.h"
// CEXDropdownComboBox

class AFX_EXT_CLASS CEXDropdownComboBox : public CComboBox
{
	DECLARE_DYNAMIC(CEXDropdownComboBox)

public:
  enum DROPDOWN_COMBO_STYLE
  {
    NOIMAGE,
    DROPDOWN_COMBO_CTRL = 20,
  };

	CEXDropdownComboBox();
	virtual ~CEXDropdownComboBox();

	BOOL SetComboBgBitmaps(UINT nBkgndID, UINT nBtnID, int nCount, 
                        COLORREF crBkgnd, int nTopHeight = 0, 
                        int nBottomHeight = 0, int nLeftWidth = 0, 
                        int nRightWidth = 20);

	BOOL SetEditBgBitmaps(UINT nBkgndID, int nCount, COLORREF crBkgnd, 
                        int nTopHeight = 0, int nBottomHeight= 0, 
                        int nLeftWidth = 0, int nRightWidth = 0);

	BOOL InitBgBitmap(CBitmap & src, CBitmap & bmpBtn, int index, int count);

	void SetFont(CFont* pFont, BOOL bRedraw = TRUE);
	void SetListColor(COLORREF crNoral, COLORREF crFocus);
	int SetCurSel(int nSelect);
	int SelectString(int nStartAfter, LPCTSTR lpszString);
	void ResetContent();
	void SetWindowText(LPCTSTR lpszString);

  void SetResSet(CEXBaseResSet* pResSet);
  CEXDropdownComboBoxResSet* m_pComboResSet;

protected:
	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
	virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMIS);

	BOOL CursorInWindow();
	void DrawFrame(CDC * pDC);
	void DrawText(CDC * pDC, int nIndex, CRect * prcText);

	void RecalcDropWidth();

protected:

	enum STATUS
	{
		normal,
		focus,
		select,
		disable
	};

	// combo
	int m_nComboTopHeight;
	int m_nComboBottomHeight;
	int m_nComboLeftWidth;
	int m_nComboRightWidth;

	UINT m_nBtnID;
	UINT m_nComboBkgndID;
	int m_nComboNumOfBgPics;

	COLORREF m_crComboBkgnd;
	COLORREF m_crListNormal;
	COLORREF m_crListFocus;
	BOOL m_bSetComboBg;

	CBitmap m_bmpBkgnd;

 	BOOL m_bSelect;

	CEXEdit m_edText;
	CEdit * m_pChildEdit;

protected:
	DECLARE_MESSAGE_MAP()
	virtual void PreSubclassWindow();
public:
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnCbnCloseup();
	afx_msg void OnCbnDropdown();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnNcPaint();
	afx_msg void OnPaint();
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnDestroy();
	afx_msg LRESULT OnDefEnchange(WPARAM w, LPARAM l);
	afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);
	afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos);
};


